package com.supermarket.shop.system.domain;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Vip {
    private Integer id;
    private String name;
    private String phone;
    private String pass;
    private Date date;

    public  Vip(Integer id, String name, String phone, String pass, Date date) {
        this.id = id;
        this.name = name;
        this.phone = phone;
        this.pass = pass;
        this.date = date;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public Vip() {
    }



    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getPass() {
        return pass;
    }

    public void setPass(String pass) {
        this.pass = pass;
    }

    public void show(){
        SimpleDateFormat sdf = new SimpleDateFormat("yy-MM-dd");
        String timePattern = sdf.format(this.date);
        System.out.println(this.id+"\t\t"+this.name+"\t\t"+this.phone+"\t\t"+this.pass+"\t\t"+timePattern+"\t\t");
    }

    public static  Vip getVip(String[] split){
        SimpleDateFormat sdf = new SimpleDateFormat("yy-MM-dd");
        Date date= null;
        try {
            date = sdf.parse(split[4]);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        Vip vip=new Vip(Integer.valueOf(split[0]),
                split[1],split[2],split[3],date);
        return vip;
    }
}
